/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.data.store;

import com.feiyue.basic.reader.pojo.Sort;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

public class SortStore extends Store {
	private static SortStore instance = null;

	public static SortStore getInstance() {
		if (instance == null)
			instance = new SortStore();
		return instance;
	}

	public List<Sort> getList() throws Exception {
		ArrayList localArrayList = new ArrayList();
		JSONArray localJSONArray = new JSONObject(super.load())
				.optJSONArray("response");
		int i = 0;
		int j = localJSONArray.length();
		while (true) {
			if (i >= j)
				return localArrayList;
			JSONObject localJSONObject = localJSONArray.optJSONObject(i);
			Sort localSort = new Sort();
			localSort.setId(localJSONObject.optLong("id"));
			localSort.setName(localJSONObject.optString("cname"));
			localArrayList.add(localSort);
			++i;
		}
	}

	public List<Sort> getListNew() throws Exception {
		ArrayList localArrayList = new ArrayList();
		JSONArray localJSONArray = new JSONObject(super.load())
				.optJSONArray("response");
		int i = 0;
		int j = localJSONArray.length();
		while (true) {
			if (i >= j)
				return localArrayList;
			JSONObject localJSONObject = localJSONArray.optJSONObject(i);
			Sort localSort = new Sort();
			localSort.setId(localJSONObject.optLong("id"));
			localSort.setName(localJSONObject.optString("name"));
			localSort.setPic(localJSONObject.optString("pic"));
			localArrayList.add(localSort);
			++i;
		}
	}
}